package Test;

public class BTree {


  public static class BNode{
        char ch;
        BNode left;
        BNode right;

      public BNode(char ch) {
          this.ch = ch;
      }
  }

public void creat(){
      BNode bNode1=new BNode('A');
      BNode bNode2=new BNode('B');
      BNode bNode3=new BNode('C');
      BNode bNode4=new BNode('D');
      BNode bNode5=new BNode('E');
      BNode bNode6=new BNode('F');
      BNode bNode7=new BNode('G');

      bNode1.left=bNode2;
      bNode1.right=bNode3;

      bNode2.left=bNode4;
      bNode2.right=bNode5;

      bNode3.left=bNode6;
      bNode3.right=bNode7;
}
//前序遍历
public void prvorder(BNode node){
      if(node==null){
          return ;
      }
    System.out.println(node.ch+" ");
prvorder(node.left);
prvorder(node.right);
}

//中序遍历
    public void inorder(BNode node){
      if(node==null){
          return ;
      }
      prvorder(node.left);
        System.out.println(node.ch+" ");
        prvorder(node.right);
    }
//后序遍历
    public void afterorder(BNode node){
      if(node==null){
          return ;
      }
      afterorder(node.left);
      afterorder(node.right);
        System.out.println(node.ch+" ");
    }



}
